﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RaiderManagerBackend;

namespace RaiderManager.EditWindows
{
    /// <summary>
    /// Interaction logic for AddEditRaidWindow.xaml
    /// </summary>
    public partial class AddEditRaidWindow : Window
    {
        private Raid r;

        private bool newRaid = false;
        public AddEditRaidWindow()
        {
            InitializeComponent();

            r = new Raid();
            newRaid = true;
            this.RaidGrid.DataContext = r;
        }

        public AddEditRaidWindow(Raid editRaid)
        {
            InitializeComponent();

            r = editRaid;
            this.RaidGrid.DataContext = r;
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Canceling will lose any edits you have made to the current raid.", "Cancel Editing?", MessageBoxButton.OKCancel);
            if (result.Equals(MessageBoxResult.Cancel))
                return;
            else if (newRaid) //If we don't set this to null on a new raid, a blank raid will be added to the raid list, but not to the database.
                r = null;
            this.Close();
        }

        private void savePlayerButton_Click(object sender, RoutedEventArgs e)
        {
            r.SaveRaid();
            this.Close();
        }

        new public Raid ShowDialog()
        {
            base.ShowDialog();
            return r;
        }

    }
}
